package com.cskaoyan.model.admin.bo;

import com.cskaoyan.bean.MarketGoods;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.math.BigDecimal;

public class GoodsEntityOfGoodsCreateBO {
    /**
     * brief : 好吃
     * keywords : 史蒂芬
     * goodsSn : 55
     * isNew : true
     * picUrl : http://182.92.235.201:8083/wx/storage/fetch/y5i8rmnsxqgepiuf2ug4.jpg
     * unit : 2
     * brandId : 1001003
     * name : 33
     * counterPrice : 88
     * detail : <p>不错，也不赖，好好加油</p>
     * isOnSale : true
     * gallery : ["http://182.92.235.201:8083/wx/storage/fetch/a54wfc3i5bl1sx7b9ogk.jpg"]
     * isHot : false
     * categoryId : 1008005
     */
    private String brief;
    private String keywords;
    private String goodsSn;
    private boolean isNew;
    private String picUrl;
    private String unit;
    private int brandId;
    private String name;
    private String counterPrice;
    private String detail;
    private boolean isOnSale;
    private String[] gallery;
    private boolean isHot;
    private int categoryId;
    private MarketGoods marketGoods = new MarketGoods();

    public void setBrief(String brief) {
        this.brief = brief;
        marketGoods.setBrief(brief);
    }

    public void setKeywords(String keywords) {
        this.keywords = keywords;
        marketGoods.setKeywords(keywords);
    }

    public void setGoodsSn(String goodsSn) {
        this.goodsSn = goodsSn;
        marketGoods.setGoodsSn(goodsSn);
    }

    public void setNew(boolean aNew) {
        isNew = aNew;
        marketGoods.setIsNew(aNew);
    }

    public void setPicUrl(String picUrl) {
        this.picUrl = picUrl;
        marketGoods.setPicUrl(picUrl);
    }

    public void setUnit(String unit) {
        this.unit = unit;
        marketGoods.setUnit(unit);
    }

    public void setBrandId(int brandId) {
        this.brandId = brandId;
        marketGoods.setBrandId(brandId);
    }

    public void setName(String name) {
        this.name = name;
        marketGoods.setName(name);
    }

    public void setCounterPrice(String counterPrice) {
        this.counterPrice = counterPrice;
        double price = Double.parseDouble(counterPrice);
        marketGoods.setCounterPrice(new BigDecimal(price));
    }

    public void setDetail(String detail) {
        this.detail = detail;
        marketGoods.setDetail(detail);
    }

    public void setOnSale(boolean onSale) {
        isOnSale = onSale;
        marketGoods.setIsOnSale(onSale);
    }

    public void setGallery(String[] gallery) {
        this.gallery = gallery;
        String strings = null;
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            strings = objectMapper.writeValueAsString(gallery);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        marketGoods.setGallery(strings);
    }

    public void setHot(boolean hot) {
        isHot = hot;
        marketGoods.setIsHot(isHot);
    }

    public void setCategoryId(int categoryId) {
        this.categoryId = categoryId;
        marketGoods.setCategoryId(categoryId);
    }

    public String getBrief() {
        return brief;
    }

    public String getKeywords() {
        return keywords;
    }

    public String getGoodsSn() {
        return goodsSn;
    }

    public boolean isNew() {
        return isNew;
    }

    public String getPicUrl() {
        return picUrl;
    }

    public String getUnit() {
        return unit;
    }

    public int getBrandId() {
        return brandId;
    }

    public String getName() {
        return name;
    }

    public String getCounterPrice() {
        return counterPrice;
    }

    public String getDetail() {
        return detail;
    }

    public boolean isOnSale() {
        return isOnSale;
    }

    public String[] getGallery() {
        return gallery;
    }

    public boolean isHot() {
        return isHot;
    }

    public int getCategoryId() {
        return categoryId;
    }

    public MarketGoods getMarketGoods() {
        return marketGoods;
    }
}
